import "./public-path.js";
import Vue from "vue";
import App from "./App";
import VueCookie from "vue-cookie";
import router from "./router";
// import 'babel-polyfill'
import qelement from "./components/integration/index.js";
import Element from "element-ui";

import "./common/styles/index.css";
import "./common/styles/index.scss";
import "@/styles/index.scss";
import AMap from "vue-amap";
Vue.use(AMap);
Vue.use(qelement);
AMap.initAMapApiLoader({
  key: "cfa678b448ac71f7a560a98397245c58",
  plugin: [
    "AMap.Scale",
    "AMap.OverView",
    "AMap.ToolBar",
    "AMap.MapType",
    "AMap.Geocoder",
    "AMap.DistrictSearch",
    "AMap.DistrictLayer"
  ]
});

import store from "./store/index";
import Echarts from "echarts";
import EchartsGl from "echarts-gl";
import "echarts/map/js/province/jiangsu";

import "echarts/extension/bmap/bmap";
import "./utils/_globalsComponets"; //文件
import moment from "moment";
Vue.prototype.$echarts = Echarts;
Vue.prototype.$echartsGl = EchartsGl;
Vue.prototype.$moment = moment;

// import axios from "axios";
// Vue.prototype.$axios = axios; //全局注册
// Vue.prototype.qs = qs;

//注册滚动条
import HappyScroll from "vue-happy-scroll";
import "vue-happy-scroll/docs/happy-scroll.css";
// 注册树形下拉框
import ElSelectTree from "el-select-tree";

Vue.use(HappyScroll);
Vue.use(ElSelectTree);
import permission from "./directive/permission";

const bus = new Vue();
Vue.prototype.bus = bus;

Vue.use(VueCookie);
Vue.use(permission);

Vue.use(Element, {
  size: VueCookie.get("size") || "medium" // set element-ui default size
});

Vue.prototype.baidumapak = "TNvtFl9IcIAfAwqHIjMGDDbfO0somydz";

Vue.config.productionTip = false;
//原
// new Vue({
//   el: '#app',
//   router,
//   store,
//   components: {
//     App
//   },
//   template: '<App/>'
// })
//现
let instance = null;
function render(props = {}) {
  const { container } = props;
  // router = new VueRouter({ routes });
  instance = new Vue({
    store,
    router,
    render: h => h(App)
  }).$mount(container ? container.querySelector("#app") : "#app");
}

// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
  let script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "https://map.sgcc.com.cn/maps?v=3.0.0";
  document.getElementsByTagName("body")[0].appendChild(script);
  setTimeout(() => {
    SGMap.tokenTask.login("86cef35df65035f8b7af4e67498db20b", "8b100c060ca8340c9c13171072307601")
  }, 1000)
  render({});
}
// 微应用生命周期函数
export async function bootstrap() {
  console.log("bootstraped");
}
export async function mount(props) {
  console.log(props);
  console.log("mount");
  render(props);
}
export async function unmount() {
  console.log("unmount");
  instance.$destroy();
  instance.$el.innerHTML = "";
  instance = null;
  // router = null;
}

